#pragma once
#include <SQLiteCpp/SQLiteCpp.h>

void DatabaseShow(const SQLite::Database &db)
{
    try
    {
        // 查询数据库中的所有表名
        SQLite::Statement query(db, "SELECT name FROM sqlite_master WHERE type='table'");

        // 遍历所有表
        while (query.executeStep())
        {
            std::string tableName = query.getColumn(0);
            std::cout << "Table: " << tableName << std::endl;

            // 查询该表的所有数据
            SQLite::Statement selectAll(db, "SELECT * FROM " + tableName);

            // 获取列数
            int numColumns = selectAll.getColumnCount();

            // 打印表的内容
            while (selectAll.executeStep())
            {
                for (int i = 0; i < numColumns; ++i)
                {
                    std::cout << selectAll.getColumn(i) << " ";
                }
                std::cout << std::endl;
            }

            std::cout << "----------------------" << std::endl;
        }
    }
    catch (const std::exception &e)
    {
        std::cerr << "Error: " << e.what() << std::endl;
    }
}